﻿@model Tuple<IEnumerable<HeadComment>, Entity, User>
@{Layout = null;}
<ul class="project_forum_list">
	@foreach (var comment in Model.Item1)
 {
		<li class="project_forum_list_item">
			<div class="project_forum_comment_container">
				@Avatar.Small(comment.Author, imageClass:"project_forum_avatar", id:"project_forum_threadstart_userpic")
				<div class="project_forum_comment">
					<span class="project_forum_header">@(comment.Author.DisplayName ?? "unknown"), @comment.DateCreated</span>
					<div class="project_forum_body">
						@comment.Text
					</div>
                    <span class="project_forum_comment_counter">
						@(comment.ChildComments.Count > 0 ? comment.ChildComments.Count.ToString() : "нет")
						@(ViewBag.WordFormatter.GetNumericalWordForm((string)"комментарий", (int)comment.ChildComments.Count))
                    </span>
					<a href="#" class="project_forum_link">Показать/скрыть комментарии</a> <a href="#" class="project_forum_link">Ответить</a>
				</div>
			</div>
			<ul class="project_forum_list">
				@foreach (var childComment in comment.ChildComments)
	{
					<li class="project_forum_list_item">
						<div class="project_forum_comment_container">
							<div class="editContainer editComment_1_remove" id="commentContainer_1">
								@Avatar.Small(childComment.Author, imageClass:"project_forum_avatar")
								<div class="project_forum_comment">
									<span class="project_forum_header">@childComment.Author.DisplayName, @childComment.DateCreated</span>
									<div class="project_forum_body">
										@childComment.Text
									</div>
									<!--<span class="project_forum_comment_counter">5 комментариев</span>-->
								</div>
							</div>
						</div>
					</li>
	}
				
				<li class="project_forum_list_item project_forum_list_itemNew">
                    <div class="project_forum_comment_container">
						@Avatar.Small(Model.Item3, imageClass: "project_forum_avatar", id: "project_forum_threadstart_userpic")
						@using (Html.BeginForm("Add", "Comment", FormMethod.Post, new { @class = "ajaxForm" } ))
	  {
		  @Html.Hidden("id", comment.Id)
		  @Html.Partial("NewComment", new { IsAuthenticated = @Model.Item3 != null, Placeholder = "Ответить" })
	  }
                    </div>
                </li>
	
			</ul>
		</li>
 }
 
 <li class="project_forum_list_item project_forum_list_itemNew">
                    <div class="project_forum_comment_container">
						@Avatar.Small(Model.Item3, imageClass: "project_forum_avatar", id: "project_forum_threadstart_userpic")
						@using (Html.BeginForm("AddHead", "Comment", FormMethod.Post, new { @class = "ajaxForm" }))
	  {
		  @Html.Hidden("storyType", Model.Item2.GetType().FullName)
		@Html.Hidden("id", Model.Item2.Id)
		@Html.Partial("NewComment", new { IsAuthenticated = @Model.Item3 != null, Placeholder = "Новое сообщение" })
	  }
                    </div>
                </li>
</ul>
 <script type="text/javascript">
						/*<![CDATA[*/
							$(document).ready(function(){
								$('.project_forum_link').click(function(){
									var container = $(this).parents('.project_forum_list_item');
									container = $(container[0]);
									container.toggleClass('project_forum_list_itemOpen');
									container.children('.project_forum_list').toggle();
									return false;
								});
								
								$('.newComment_textarea').focus(function(){ 
									$(this).css({'height':'5em'}).next('.newComment_buttonsContainer').show();
								}).blur(function(){
									if ($(this).val() == '') {
										$(this).removeAttr('style').next('.newComment_buttonsContainer').hide();
									}
								});

							});


						/*]]>*/
                        </script>
